<template>
    <div></div>
</template>

<script>
    export default {
        name: "author",
        created() {
            var code = this.getQueryString('code')
            let url = window.localStorage.getItem("beforeLoginUrl");
            //发送请求去获取oppenid
            let data={"code":code}
            this.http.get('/app/wechat/VueJieru/getCode/mid/2',data).then(res=>{
               if (res.data){
                   window.localStorage.setItem("user_token",res.data.openid);
                   // //跳转
                   this.$router.push(url);
               }
            })

        },
        methods:{
            getQueryString(name){
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) {
                    return unescape(r[2]);
                }else {
                    return null;
                }
            },
        }
    }
</script>

<style scoped>

</style>
